package com.anjiplus.template.gaea.business.modules.flowable.model.controller;

import com.anji.plus.gaea.bean.ResponseBean;
import com.anji.plus.gaea.curd.controller.GaeaBaseController;
import com.anji.plus.gaea.curd.service.GaeaBaseService;
import com.anjiplus.template.gaea.business.modules.flowable.model.controller.dto.ActDeModelDTO;
import com.anjiplus.template.gaea.business.modules.flowable.model.controller.param.ActDeModelParam;
import com.anjiplus.template.gaea.business.modules.flowable.model.dao.entity.ActDeModel;
import com.anjiplus.template.gaea.business.modules.flowable.model.service.ActDeModelService;
import io.swagger.annotations.Api;
import org.flowable.engine.repository.Deployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * (ActDeModel)实体类
 *
 * @author lirui
 * @since 2021-03-17 15:53:44
 */
@RestController
@RequestMapping("/actDeModel")
@Api(value = "/actDeModel", tags = "")
public class ActDeModelController extends GaeaBaseController<ActDeModelParam, ActDeModel, ActDeModelDTO> {
    @Autowired
    private ActDeModelService actDeModelService;

    @Override
    public GaeaBaseService<ActDeModelParam, ActDeModel> getService() {
        return actDeModelService;
    }

    @Override
    public ActDeModel getEntity() {
        return new ActDeModel();
    }

    @Override
    public ActDeModelDTO getDTO() {
        return new ActDeModelDTO();
    }


    /**
     * 部署模型为流程
     * @param modelId
     * @return
     */
    @GetMapping("/publish/{modelId}")
    public ResponseBean publishModel(@PathVariable("modelId") String modelId) {
        Deployment deployment = actDeModelService.publishModel(modelId);
        return responseSuccessWithData(deployment);
    }
}
